import { createRenderer } from "../runtime-core";
let renderer;
export type NodeOps = typeof nodeOps;
const nodeOps = {
  insert(child: HTMLElement, parent: HTMLElement, anchor?: HTMLElement) {
    parent.insertBefore(child, anchor || null);
  },
  patchProp(el: HTMLElement, key: string, ov: any, nv: any) {
    el.setAttribute(key, nv);
  },
  remove(child: HTMLElement) {
    const parent = child.parentNode;
    if (parent) {
      parent.removeChild(child);
    }
  },
  createElement(type: string) {
    return document.createElement(type);
  },
  createText(text: string) {
    return document.createTextNode(text);
  },
  setText(node: HTMLElement, text: string) {
    node.nodeValue = text;
  },
  setElementText(el: HTMLElement, text: string) {
    el.textContent = text;
  },
  parentNode: (node: HTMLElement) => node.parentNode,
  nextSibling: (node: HTMLElement) => node.nextSibling,
  querySelector: (selector: string) => document.querySelector(selector),
  setScopeId(el: HTMLElement, id: string) {
    el.setAttribute(id, "");
  },
};
function ensureRenderer() {
  // 缓存
  return renderer || (renderer = createRenderer(nodeOps));
}

export function createApp() {}
